﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    public delegate double CalculatorDelegate(double num1, double num2); // 委托
    class Program
    {
        static void Main(string[] args)
        {
           
            //等效于AddNum方法
            CalculatorDelegate calculatorDel = delegate(double x, double y)
            { return x + y; };
            Console.WriteLine("委托一个方法的结果为:{0}", calculatorDel(1, 2));
           
            // 等效于SumNum方法
            calculatorDel += (x, y) => { return x - y; };
            Console.WriteLine("委托两个方法的结果为:{0}", calculatorDel(1, 2));
            Console.ReadKey();
        }
    }
}
